import request from "@/utils/http"
import type { MemberAddress, AddressParams } from "@/types/MemberAddress"

// 获取会员所有地址
export const getMemberAddressApi = () => {
  return request<MemberAddress[]>({
    url:'ums/front/address/list',
    method:'GET',
  })
}

// 根据地址id回显地址数据
export const getAddressInfoApi = (id:number) => {
  return request<MemberAddress>({
    url:`ums/front/address/${id}`,
    method:'GET',
  })
}

// 修改地址信息
export const updateAddressInfoApi = (id:number, data:AddressParams) => {
  return request<AddressParams>({
    url:`ums/front/address/update/${id}`,
    method:'PUT',
    data,
  })
}

// 新增地址信息
export const addAddressInfoApi = (data:AddressParams) => {
  return request<AddressParams>({
    url:'ums/front/address/add',
    method:'POST',
    data,
  })
}

// 删除地址信息
export const deleteAddressInfoApi = (id:number) => {
  return request<AddressParams>({
    url:`ums/front/address/delete/${id}`,
    method:'DELETE',
  })
}